package com.cysoft.starter.log.core.configuration;

import com.cysoft.starter.log.config.LogAutoConfiguration;
import com.cysoft.starter.log.core.aspect.LogAspect;
import com.cysoft.starter.log.core.properties.OperateLogProperties;
import com.cysoft.starter.log.core.repository.impl.DefaultRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 玖零
 * @version v0.0.1
 * @project cysoft-spring-boot-starter-log
 * @package com.cysoft.starter.log.core.configuration
 * @date 2025-02-06 21:26
 * @desc TODO
 */
@Slf4j
@Configuration
@ConditionalOnBean(name = "defaultConfiguration")
@AutoConfigureAfter(LogAutoConfiguration.class)
public class DefaultConfiguration {

    /**
     * 操作日志配置信息
     */
    private final OperateLogProperties operateLogProperties;

    /**
     * 默认日志切面配置 构造方法
     * @param operateLogProperties
     */
    public DefaultConfiguration(OperateLogProperties operateLogProperties) {
        this.operateLogProperties = operateLogProperties;
    }

    @Bean
    public LogAspect defaultLogAspect(){
        log.info("******************开始初始化defaultLogAspect******************");
        log.info("开始构建default日志切面");
        LogAspect logAspect = new LogAspect(new DefaultRepository(), operateLogProperties);
        log.info("default日志切面构建成功，日志切面对象: {}", logAspect);
        return logAspect;
    }


}
